<template>
    <div class="hospital">
        <!-- 左侧路由导航区域 -->
        <div class="menu">
            <div class="top">
                <el-icon><House /></el-icon>
                <span> / 医院信息</span>
            </div>
            <el-menu
            :default-active="route.path"
            class="el-menu-vertical-demo"
          >
            <el-menu-item index="/hospital/register" @click="gotoRight('/hospital/register')">
              <el-icon><Calendar/></el-icon>
              <span>预约挂号</span>
            </el-menu-item>
            <el-menu-item index="/hospital/detail" @click="gotoRight('/hospital/detail')">
              <el-icon><document /></el-icon>
              <span>医院详情</span>
            </el-menu-item>
            <el-menu-item index="/hospital/notice" @click="gotoRight('/hospital/notice')">
              <el-icon><Bell /></el-icon>
              <span>预约须知</span>
            </el-menu-item>
            <el-menu-item index="/hospital/close" @click="gotoRight('/hospital/close')">
                <el-icon><Warning /></el-icon>
            <span>停诊信息</span>
                </el-menu-item>
            <el-menu-item index="/hospital/search" @click="gotoRight('/hospital/search')">
                <el-icon><Search /></el-icon>
                <span>查询/取消</span>
            </el-menu-item>
          </el-menu>
        </div>

        <!-- 右侧路由展示区域 -->
        <div class="content">
            <!-- 子路由展示区域 -->
            <router-view></router-view>
        </div>
    </div>
</template>

<script setup lang="ts">
import {Document, Calendar, Warning, House, Bell, Search } from '@element-plus/icons-vue'
import { onMounted } from 'vue';
// 引入路由器/路由
import { useRouter,useRoute } from 'vue-router';
// 引入医院详情仓库
import useDetailStore from '@/store/modules/hospitalDetail'

// 创建一个仓库实例
let detailStore = useDetailStore();
// 创建路由器实例
let router = useRouter();
// 创建路由实例
let route = useRoute();
// 左侧导航菜单点击事件的回调，子路由跳转
const gotoRight = (path:string)=>{
    router.push({path,query:{hoscode: route.query.hoscode }})
}
// 组件挂载完毕，调用仓库中的方法获取医院详情
onMounted(()=>{
    detailStore.getHospitalDetail((route.query.hoscode as string));
    detailStore.getDepartment((route.query.hoscode as string));
})
</script>

<style scoped lang="scss">
.hospital{
    display: flex;
    margin-top: 17px;
    .menu{
        flex: 2;
        .top{
            margin-left: 30px;
            margin-bottom: 10px;
            font-size: 14px;
            color: #7f7f7f;
            display: flex;
            align-items: center;
            span{
                margin-left: 5px;
            }
        }
    }
    .content{
        flex: 10;
        margin-left: 20px;
    }
}
</style>